package net.expectx.pay;


import net.expectx.common.single.util.AesUtil;
import net.expectx.common.single.util.MybatisGeneratorUtil;
import net.expectx.common.single.util.PropertiesFileUtil;
import net.expectx.common.single.util.RedisUtil;
import net.expectx.pay.core.api.PaymentHandlerInterface;
import net.expectx.pay.core.common.EXPayResult;
import net.expectx.pay.core.service.provider.ProviderWXPayAppletDriver;

import java.util.HashMap;
import java.util.Map;

/**
 * 代码生成类
 * @author lijian
 * @date 2018/7/21
 */
public class Generator {

	/**
	 * 根据命名规范，只修改此常量值即可
	 */
	/**
	 * 模块名
	 */
	private static String MODULE = "E-XPay";
    /**
     * 包名
     */
    private static String PACKAGE_NAME = "net.expectx.pay";

	private static String DATABASE = "e-x-pay";

    /**
     * 是否模糊查询
     */
	private static boolean isLike=false;
	/**
	 * 表名前缀
	 */
	private static String TABLE_PREFIX = "product_order_header";



	private static String JDBC_DRIVER = PropertiesFileUtil.getInstance("jdbc").get("jdbc.driver");

	private static String JDBC_URL = PropertiesFileUtil.getInstance("jdbc").get("jdbc.url");

	private static String JDBC_USERNAME = PropertiesFileUtil.getInstance("jdbc").get("jdbc.username");

	private static String JDBC_PASSWORD = AesUtil.aesDecode(PropertiesFileUtil.getInstance("jdbc").get("jdbc.password"));

	/**
	 * 需要insert后返回主键的表配置，key:表名,value:主键名
	 */
	private static Map<String, String> LAST_INSERT_ID_TABLES = new HashMap<>();

	static {
		LAST_INSERT_ID_TABLES.put("system_log_copy", "id");
	}

	/**
	 * 自动代码生成
	 * @param args
	 */
	public static void main(String[] args) throws Exception {
		MybatisGeneratorUtil.generator(JDBC_DRIVER, JDBC_URL, JDBC_USERNAME, JDBC_PASSWORD, MODULE,
				DATABASE, TABLE_PREFIX, PACKAGE_NAME, LAST_INSERT_ID_TABLES);
//        Map<String, Object> payParams = new HashMap<>();
//        PaymentHandlerInterface paymentHandlerInterface = new ProviderWXPayAppletDriver();
//        payParams.put("subAppId","wxa095e06a92f8d952");
//        payParams.put("subMchId", "1546196471");
//        payParams.put("notifyUrl", "1111");
//        payParams.put("body", "1111");
//        payParams.put("outTradeNo",System.currentTimeMillis());
//        payParams.put("totalFee", "0.01");
//        payParams.put("createIp","127.0.0.1");
//        payParams.put("subOpenId", "owU6X5PLchrYE0BBKhJrPc9yZWnI");
//        EXPayResult exPayResult=paymentHandlerInterface.doPay(payParams);
//        System.out.println(exPayResult);
//        System.out.println(111);

	}

}
